import java.io.*;
import javazoom.jl.player.Player; // tải thư viện

import java.io.BufferedInputStream;
import java.io.FileInputStream;




public class MP3Player{
private String filename ;
private Player player;
public MP3Player(String filename) {
this.filename = filename;
}

public void close() { if (player != null) player.close(); }

public void play() {
try {
FileInputStream fis = new FileInputStream(filename);
BufferedInputStream bis = new BufferedInputStream(fis);
player = new Player(bis);
// Manager p = new Manager();

}
catch (Exception e) {

}

new Thread() {
@Override
public void run() {
try { player.play(); }
catch (Exception e) { System.out.println(e); }
}
}.start();
}


// test client
public static void main(String[] args) {
String filename = "D:/dongthoigian.mp3";// ten bai hat can play
MP3Player mp3 = new MP3Player(filename);
mp3.play();
}

} 
